<template>
	<view class="control">
		<view class="box-1">
			<view class="data-item flex-align">
				<view class="image">
					<u--image :src="cardData.picture" width="289rpx" height="183rpx" radius="5"></u--image>
				</view>

				<view class="detail">
					<view>
						<view class="title ellipsis-1">{{ cardData.name }}</view>
						<view class="tag-list flex-align">
							<view class="tag" v-for="(item, index) in cardData.venues_project" :key="index">
								{{ item.name }}
							</view>
						</view>
						<!-- 计次卡 -->
						<view class="tiemr ellpisis-1"
							style="font-size: 26rpx;margin-top: 20rpx;color: #ffaa00;font-weight: bold;"
							v-show="cardData.type == 1">{{ cardData.times }}次 <text v-show="cardData.gifts != ''">
								+{{ cardData.gifts }}次</text></view>
						<!-- 金额卡 -->
						<view class="tiemr ellpisis-1"
							style="font-size: 26rpx;margin-top: 20rpx;color: #ffaa00;font-weight: bold;"
							v-show="cardData.type == 3">{{ cardData.times }}元<text v-show="cardData.gifts != ''">
								+{{ cardData.gifts }}元</text></view>
						<!-- 时间卡 -->
						<view class="tiemr ellpisis-1"
							style="font-size: 26rpx;margin-top: 20rpx;color: #ffaa00;font-weight: bold;"
							v-show="cardData.type == 2">{{ cardData.times }}天<text v-show="cardData.gifts != ''">
								+{{ cardData.gifts }}天</text></view>
						<!-- <view class="info ellipsis-1">“充300元送20”</view> -->
					</view>
					<view class="flex-between">
						<view class="price">￥{{ cardData.selling_price }}</view>
						<view class="price-2" v-if="cardData.volume > cardData.sale_num">销量：{{cardData.volume}}</view>
						<view class="price-2" v-if="cardData.volume < cardData.sale_num">销量：{{cardData.sale_num}}</view>
					</view>
				</view>
			</view>
		</view>

		<view class="box-2">
			<!-- <view class="title">适用场馆</view> -->
			<view class="flex-between" @click="openStoreShow">
				<u-image :src="`${assetsPath}44d8d751bb60e10cc8e83c114d488541605662f5.png`" width="30rpx" height="30rpx"
					shape="square"></u-image>
				<view class="name" style="white-space: nowrap;
									overflow: hidden;
									text-overflow: ellipsis;width: 444rpx;">{{ venue_name }}</view>
				<view class="flex-align icon">
					<text>适用<text style="color: orange; text-align: center; margin: 0">{{cardDatalength}}</text>个场馆</text>
					<u-icon name="arrow-right" color="rgb(153,153,153)" size="14"></u-icon>
				</view>
			</view>
		</view>

		<view class="box-3">
			<view class="flex-between image-1">
				<image
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/23486c439eebab21a0831787cad64d5ec2259398.png">
				</image>
				<image mode="aspectFit"
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/f2026f5c65ac585d47b3eef17833b262f362643a.png">
				</image>
				<image
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/cc377ae2075d6caa0f357da921b71bc58a241c79.png">
				</image>
				<image mode="aspectFit"
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/f2026f5c65ac585d47b3eef17833b262f362643a.png">
				</image>
				<image
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/14c51739ebdaf6d43df36b9b2423e843ef9cd9bc.png">
				</image>
				<image mode="aspectFit"
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/f2026f5c65ac585d47b3eef17833b262f362643a.png">
				</image>
				<image
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/da98d0fe4de57b84884b7b6e3998dfcb82e7c6a1.png">
				</image>
			</view>
			<view class="flex-between">
				<text>选择商品</text>
				<text>付款成功</text>
				<text>获取二维码</text>
				<text>到店核销</text>
			</view>
		</view>

		<view class="box-4">
			<!-- <u-tabs :list="list1" lineWidth="30" @click="changeTab" :activeStyle="{
          color: 'rgb(47,117,250)',
          fontWeight: '700',
          fontSize: '28rpx',
        }" :inactiveStyle="{ color: 'rgb(153,153,153)', fontSize: '26rpx' }">
			</u-tabs>
			<view class="con" v-show="tabActiveIndex == index" v-for="(item, index) in list1">
				{{ item.name }}
			</view> -->
			<view class="con" >
				<u-parse :content="cardData.buy_content"></u-parse>
			</view>
		</view>

		<view class="box-2">
			<!-- <view class="title">详情</view> -->
			<u-parse :content="cardData.content"></u-parse>
		</view>
		<!-- time_start:'',
		sale_end :'',
		sale_start :'' -->
		<view class="" v-if="time_start > sale_start && time_start < sale_end">
			<view class="footer flex-align" v-if="cardData.quantity > 0 || !cardData.inventory">
				<!-- <view class="menu">
					<image mode="aspectFit" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/e04921dea41d1323bb7d5b6fc91349c0d030bd9a.png"></image>
					<text>店铺</text>
				</view> -->
				<footerLeft></footerLeft>
				<!-- <view class="btn" @click="openSelectAlert">立即购买</view> -->
				<view class="btn" @click="handSubmit">立即购买</view>
			</view>
			<view class="footer flex-align" v-if="cardData.quantity == 0 && cardData.inventory">
				<footerLeft></footerLeft>
				<view class="btn_n">立即购买</view>
			</view>
		</view>
		<!-- 场馆 -->
		<con-alert :show="alertShow" @close="close" isFooter>
			<!-- <view class="section"> -->
				<view class="select-list">
					<view class="item flex-align" v-for="item in cardData.venues" :key="item" @click="cardlist(item)">
						<view class="image">
							<u--image radius="5" :src="item.venue_thumb" width="100%" height="100%"></u--image>
						</view>
						<view class="detail">
							<view>
								<view class="name"> {{ item.venue_name }} </view>
								<view class="timer"> 营业时间：{{ item.open_time }} </view>
							</view>

							<view class="flex-between bottom">
								<view class="flex-align" style="width: 70%">
									<u-icon name="map-fill" color="#cacaca" size="12"></u-icon>
									<text class="address">{{ item.address }}</text>
								</view>
								<view class="flex-align">
									<text>{{ item.phone }}</text>
									<u-icon name="phone" color="#cacaca" size="12"></u-icon>
								</view>
							</view>
						</view>
					</view>
				</view>
			<!-- </view> -->
		</con-alert>
		<!-- 选择弹窗 -->
		<con-alert isFooter :show="selectAlertShow" @close="close2">
			<view class="section">
				<view class="section-1 flex-align">
					<view class="image">
						<u--image src="https://cdn.uviewui.com/uview/album/1.jpg" width="100%" height="100%">
						</u--image>
					</view>

					<view class="detail">
						<view>
							<view class="title2 ellipsis-1">雪雁的时代的hi我IHI第啊打完我</view>
							<view class="tag-list flex-align">
								<view class="tag">游泳</view>
							</view>
						</view>
						<view class="flex-between">
							<view class="price">￥30.00</view>
						</view>
					</view>
				</view>
				<view class="section-2" v-for="item in 1" :key="item">
					<view class="sub-title">选择项目</view>
					<view class="tag-list">
						<view class="tag" v-for="item in 8" :key="item">羽毛球</view>
					</view>
				</view>
				<view class="section-2 flex-between" v-for="item in 1" :key="item">
					<view class="sub-title">购买数量</view>
					<u-number-box disabled v-model="value" s></u-number-box>
				</view>
				<view class="section-3">剩余：8</view>
			</view>
		</con-alert>
	</view>
</template>

<script>
	import conAlert from "@/components/com-alert/com-alert.vue";
	import footerLeft from "@/components/footer-left/footer-left.vue";
	const venues = require("@/api/venues/venues.js");
	export default {
		data() {
			return {
				assetsPath: this.$https.assetsPath,
				alertShow: false,
				selectAlertShow: false, //选择商品
				tabActiveIndex: 0,
				list1: [{
						name: "购买说明",
					},
					{
						name: "用户须知",
					},
				],
				timeData: {},
				value: 0,
				cardData: {},
				project_id: "",
				card_id: "",
				appid: "",
				venue_id: "",
				venue_name: "",
				time_start: '',
				sale_end: '',
				sale_start: '',
				cardDatalength:''
			};
		},
		components: {
			conAlert,
			footerLeft
		},
		onLoad(options) {
			this.project_id = getApp().globalData.projectId,
			this.card_id = options.id;
			this.appid = this.$https.weixinAppId;
			this.venue_id = options.venue_id;
			this.venue_name = options.venue_name;
			let postData = {
				project_id: this.project_id,
				card_id: this.card_id,
				appid: this.appid,
				venue_id: this.venue_id,
			};
			this.getCardDetail(postData);
		},
		methods: {
			cardlist(item) {
				// this.venue_name = item.venue_name
			},
			// 获取会员卡详情
			async getCardDetail(postData) {
				let res = await venues.getMemberCard(postData);
				if (res.code == 1) {
					this.cardData = res.data;
					this.cardDatalength = res.data.venues.length
					let sale_end = res.data.sale_end
					let sale_start = res.data.sale_start
					this.sale_end = new Date(sale_end.replace(/-/g, '/')).getTime(); //结束时间
					this.sale_start = new Date(sale_start.replace(/-/g, '/')).getTime(); //开始时间
					this.time_start = new Date().getTime()
				}
			},
			handSubmit() {
				if (uni.getStorageSync("openid") == '') {
					uni.showToast({
						title: '请登录！',
						icon: 'exception',
						duration: 850
					});
					uni.reLaunch({
						url: '/pages/personal/personal'
					})
				}else {
					let card_id = this.card_id;
					uni.navigateTo({
						url: "/page_venues/pages/venuesDetail/ticketModule/makeOther_fuzhi?ticketID=" +
							card_id +
							"&venue_name=" +
							this.venue_name +
							"&venue_id=" +
							this.venue_id +
							"&pay_wait_time=" +
							this.cardData.pay_wait_time + "&goods_type=card" +
							"&inventory=" + 1 + "&windows=" + this.cardData.windows,
					});
				}

			},
			changeTab(data) {
				this.tabActiveIndex = data.index;
			},
			close2() {
				this.selectAlertShow = false;
			},
			openSelectAlert() {
				this.selectAlertShow = true;
			},
			close() {
				this.alertShow = false;
			},
			openStoreShow() {
				this.alertShow = true;
			},
			onChange(e) {
				this.timeData = e;
			},
		},
	};
</script>

<style lang="scss" scoped>
	.u-content {
		padding: 24rpx;
	}
	.control {
		width: 100%;
		background-color: #f3f3f3;
		// min-height: 100vh;
		height: 100vh;
		overflow-y: auto;
		padding-bottom: 140rpx;

		.box-1 {
			padding: 30rpx 30rpx;
			background-color: rgb(255, 255, 255);

			.data-item {
				margin-top: 20rpx;
				height: 220rpx;
				padding: 10rpx;

				.image {
					width: 300rpx;
					height: 100%;

					/deep/ .u-fade-enter-to {
						height: 100%;
					}
				}

				.detail {
					height: 100%;
					width: 0;
					flex: 1;
					margin-left: 25rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.title {
						font-size: 30rpx;
						margin-bottom: 10rpx;
					}

					.tag-list {
						margin-bottom: 10rpx;

						.tag {
							font-size: 20rpx;
							// color: white;
							border-radius: 4rpx;
							padding: 5rpx 10rpx;
							color: black;
							background-color: #e7e7e7;
							// background-color: #2979ff;
							margin-right: 10rpx;
						}
					}

					.info {
						font-weight: 700;
						font-size: 25rpx;
						color: #ff4811;
					}

					.price {
						font-size: 32rpx;
						color: #ff4811;
						font-weight: 700;
						margin-right: 10rpx;
					}

					.price-2 {
						color: #bebebe;
						font-size: 24rpx;
					}
				}
			}
		}

		.box-2 {
			margin-top: 20rpx;
			padding: 30rpx 30rpx;
			background-color: rgb(255, 255, 255);

			.title {
				color: rgb(47, 117, 250);
				font-size: 28rpx;
				font-weight: 700;
				margin-bottom: 40rpx;
			}

			.name {
				color: rgb(51, 51, 51);
				font-size: 28rpx;
				font-weight: 700;
			}

			.icon {
				color: rgb(153, 153, 153);
				font-size: 28rpx;

				text {
					margin-right: 10rpx;
				}
			}
		}

		.box-3 {
			padding: 40rpx 20rpx 25rpx 29rpx;
			color: rgb(51, 51, 51);
			font-size: 24rpx;
			font-weight: 700;
			background-color: rgb(255, 255, 255);

			.image-1 {
				padding: 0 24rpx;
				margin-bottom: 26rpx;

				image {
					width: 47rpx;
					height: 46rpx;
				}
			}
		}

		.box-4 {
			margin-top: 20rpx;
			// padding: 0rpx 20rpx 40rpx 29rpx;
			padding: 30rpx 30rpx;
			color: rgb(51, 51, 51);
			background-color: rgb(255, 255, 255);

			.con {
				// margin-top: 20rpx;
			}
		}

		.footer {
			position: fixed;
			width: 100%;
			background-color: white;
			bottom: 0;
			left: 0;
			padding: 20rpx 25rpx 20rpx 25rpx;
			box-sizing: border-box;

			.menu {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-right: 40rpx;

				image {
					width: 35rpx;
					height: 35rpx;
				}

				text {
					color: rgb(51, 51, 51);
					font-size: 24rpx;
					font-weight: 700;
					margin-top: 13rpx;
				}
			}

			.btn {
				flex: 1;
				color: rgb(255, 255, 255);
				font-size: 30rpx;
				padding: 26rpx 0;
				border-radius: 60rpx;
				background-color: #3e80fc;
				text-align: center;
				font-weight: 700;
			}

			.btn_n {
				flex: 1;
				color: rgb(255, 255, 255);
				font-size: 30rpx;
				padding: 26rpx 0;
				border-radius: 60rpx;
				background-color: #a6a6a6;
				text-align: center;
				font-weight: 700;
			}
		}

		// 弹窗
		.select-list {
			.item {
				margin-bottom: 20rpx;
				padding-bottom: 20rpx;
				height: 150rpx;
				border-bottom: 1px solid #cccccc;

				&:last-of-type {
					border: none;
					margin: 0;
					padding: 0;
				}

				.image {
					width: 150rpx;
					height: 100%;

					/deep/ .vue-ref {
						width: 100%;
						height: 100%;
					}
				}

				.detail {
					display: flex;
					height: 100%;
					flex: 1;
					width: 0;
					margin-left: 20rpx;
					flex-direction: column;
					justify-content: space-between;

					.name {
						font-weight: 700;
						font-size: 28rpx;
						margin-bottom: 15rpx;
					}

					.timer {
						color: #cacaca;
						font-size: 20rpx;
					}

					.bottom {
						font-size: 20rpx;
						color: #cacaca;

						.address {
							width: 70%;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}
				}
			}
		}

		.section {
			.section-1 {
				height: 200rpx;

				.image {
					width: 300rpx;
					height: 100%;

					/deep/ .u-fade-enter-to {
						height: 100%;
					}
				}

				.detail {
					height: 100%;
					width: 0;
					flex: 1;
					margin-left: 25rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.title2 {
						font-size: 28rpx;
						margin-bottom: 10rpx;
					}

					.tag-list {
						margin-bottom: 10rpx;

						.tag {
							font-size: 22rpx;
							color: white;
							border-radius: 10rpx;
							padding: 5rpx 10rpx;
							color: black;
							background-color: #e7e7e7;
							margin-right: 10rpx;
						}
					}

					.price {
						font-size: 32rpx;
						color: #ff4811;
						font-weight: 700;
						margin-right: 10rpx;
					}
				}
			}

			/deep/ .u-number-box {
				.u-number-box__minus,
				.u-number-box__plus,
				.u-number-box__input {
					width: 45rpx !important;
					font-size: 24rpx !important;
					height: 45rpx !important;
					border-radius: 50%;

					text {
						font-size: 24rpx !important;
					}
				}

				.u-number-box__input {
					background-color: transparent !important;
				}
			}

			.section-2 {
				margin-top: 50rpx;

				.sub-title {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
					margin-bottom: 20rpx;
				}

				.tag-list {
					display: flex;
					flex-wrap: wrap;

					.tag {
						background: #efefef;
						border-radius: 3px;
						font-size: 24rpx;
						font-weight: 500;
						color: #ffffff;
						padding: 7rpx 20rpx;
						margin-right: 20rpx;
						margin-bottom: 20rpx;
					}
				}
			}

			.section-3 {
				font-size: 22rpx;
				font-weight: 500;
				color: #333333;
			}
		}
	}
</style>
